<?php
    namespace Home\Controller;
    use Think\Controller;
    class IndexController extends Controller {
        var $ROOT;
        public function index($tab = 0){
            $Usr = D('Home/Usr') ;
            $Usrg  = new \Home\Model\UsergroupModel();
            $this->ROOT = $Usrg->Init(session('root'));
            $this->assign('tab',$tab);
            $this->assign('cct',$this->Page($tab));
            if(!$this->is_login()){
                redirect(U('Login/index'),1,'<meta charset="utf-8">请登录后使用,正在为你跳转！');
            } 
            $this->display();
        }
        public function getleftnavfloder(){
            $this->ajaxReturn($this->fetch('lnf'));
        }
        public function Page($tab){
            if($tab != 0){
                switch ($tab) {
                    case 1:
                        if ($this->ROOT['page1']) {
                            redirect(U('CKB/Index/index'),1,'Go to CKB');
                        }else {
                            return $this->fetch('qxb');
                        }
                        break;
                    case 2:
                        if ($this->ROOT['page2']) {
                            return '未开发';
                        }else {
                            return $this->fetch('qxb');
                        }
                        break;
                    case 3:
                        if ($this->ROOT['page3']) {
                            return $this->fetch('Complain/index');
                        }else {
                            return $this->fetch('qxb');
                        }
                        break;
                    case 4:
                        if ($this->ROOT['page4']) {
                            return $this->fetch('Complain/atc');
                        }else {
                            return $this->fetch('qxb');
                        }
                        break;
                    case 5:
                        if ($this->ROOT['page5']) {
                            return $this->fetch(T('Npfe@Qc/index'));
                        }else {
                            return $this->fetch('qxb');   
                        }
                        break;
                    case 6:
                        return "正在加載中，如果您很久都沒在看到頁面，可能此功能還在建設中或維護中！";
                        break;
                    case 7:
                        if ($this->ROOT['npfe']) {
                            return $this->fetch(T('Npfe@Index/index'));
                        }else {
                            return $this->fetch('qxb');
                        }
                        break;
                    default:
                        return $this->fetch('qxb');
                        break;
                }
            }

        }

        public function is_login(){
            $UserID = session('uid');
            if(empty($UserID)){
                return false;
            }else{
                return true;
            }
        }
}